require 'rubygems'
require 'wx'

class Obj_ctl_timer
	def initialize(parent, timer = 300, interval=100)
		@parent = parent
		@interval = interval
		@time_timer = timer

		# Text Timer
		label3 = Wx::StaticText.new(parent, -1, 'Timer:', [50, 163], [38, 20])
		@text_timer = Wx::TextCtrl.new(parent, -1, '', [90, 160], [80, 21], Wx::TE_READONLY|Wx::ALIGN_RIGHT)

		call_starttimer()
	end

	def call_starttimer(interval=@interval)
		day = Time.now
		@time_end = day + @time_timer
		@interval = interval

		@wxobj_timer = Wx::Timer.every(@interval) do
			update()
		end
	end


	def call_stoptimer
		@wxobj_timer.stop
	end

	def update()
		day = Time.now
		str = sprintf("%8.3f", @time_end - day)
		@text_timer.set_value(str)
	end

end
